package com.nc.delivery_project.shared.locator;

import com.google.web.bindery.requestfactory.shared.Locator;
import com.nc.delivery_project.server.domain.Role;
import com.nc.delivery_project.server.service.RoleService;
import com.nc.delivery_project.server.service.UserService;
import com.nc.delivery_project.shared.servicelocator.RoleServiceLocator;
import com.nc.delivery_project.shared.servicelocator.UserServiceLocator;

import java.util.Locale;

/**
 * Created by miroshnik on 12/28/2014.
 */
public class RoleLocator extends Locator<Role, Integer> {
    @Override
    public Role create(Class<? extends Role> aClass) {
        return new Role();
    }

    @Override
    public Role find(Class<? extends Role> aClass, Integer id) {
        return ((RoleService) new RoleServiceLocator().getInstance(null)).read(id);
    }

    @Override
    public Class<Role> getDomainType() {
        return Role.class;
    }

    @Override
    public Integer getId(Role role) {
        return role.getId();
    }

    @Override
    public Class<Integer> getIdType() {
        return Integer.class;
    }

    @Override
    public Object getVersion(Role role) {
        return role.getId();
    }
}
